/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dswII.biblioteca.bl;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.its.dswII.biblioteca.enumeracion.EstadoTransaccion;
import mx.its.dswII.biblioteca8e.dao.LibroDaoLocal;
import mx.its.dswII.biblioteca8e.modelo.Libro;

/**
 *
 * @author MAXXWELL
 */
@Stateless
public class LibroBl implements LibroBlLocal {
    @EJB
    private LibroDaoLocal libroDao;

    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public EstadoTransaccion register(Libro book) {
        if(book.getId()==null || libroDao.find(book.getId())==null){
        return EstadoTransaccion.INCOMPLETO;
        }else{
            libroDao.create(book);
            return EstadoTransaccion.COMPLETO;
        }
    }

    @Override
    public EstadoTransaccion delete(Libro book) {
        if(book.getId()==null || libroDao.find(book.getId())==null){
        return EstadoTransaccion.INCOMPLETO;
        }else{
            libroDao.remove(book);
            return EstadoTransaccion.COMPLETO;
        }
    }

    @Override
    public EstadoTransaccion modify(Libro book) {
        if(book.getId()==null || libroDao.find(book.getId())==null){
        return EstadoTransaccion.INCOMPLETO;
        }else{
            libroDao.edit(book);
            return EstadoTransaccion.COMPLETO;
        }
    }

    @Override
    public List<Libro> findAll(Libro book) {
        return libroDao.findAll();
    }

    
}
